package com.atguigu.principle;

/**
 * @author LYJ
 * @Description
 * @date 2021 年 09 月 08 日 下午4:50
 */
public class Inversion {
    public static void main(String[] args) {
        Person person = new Person();
        System.out.println(person.getInfo(new Email()));
        System.out.println(person.getInfo(new WX()));

    }
}


interface IReceiver {
    String getInfo();
}

class Email implements IReceiver {

    @Override
    public String getInfo() {
        return "邮件信息";
    }
}

class WX implements IReceiver {

    @Override
    public String getInfo() {
        return "微信信息";
    }
}

class Person {
    String getInfo(IReceiver receiver) {
        return receiver.getInfo();
    }
}


//这样明显不可取,因为改动太大
//class WX {
//
//}
//class Email {
//
//}

//class Person {
//    public String getInfo(Email email) {
//        return "收到的信息是: 电子邮件信息";
//    }
//
//    public String getInfo(WX wx){
//        return "收到的信息是: 微信";
//    }
//}


